package com.hs.telepass.manager;

import android.content.Context;
import com.hs.telepass.Constants;
import com.hs.telepass.MainApp;
import com.hs.telepass.utils.PreferencesUtil;
import com.hs.telepass.utils.StringUtil;

public class PreferencesManager {
    private static PreferencesManager mInstance;
    private Context mContext;


    public PreferencesManager(){
        mContext = MainApp.getInstance();
    }

    public static PreferencesManager getInstance(){
        if(null == mInstance)
            mInstance = new PreferencesManager();
        return mInstance;
    }

    public boolean getTelepassLoginSwitch(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_TELEPASS_LOGIN_SWITCH);
    }

    public void setTelepassLoginSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_TELEPASS_LOGIN_SWITCH, isOn);
    }

    public boolean getSingouLoginSwitch(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_SINGOU_LOGIN_SWITCH);
    }

    public void setSingouLoginSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_SINGOU_LOGIN_SWITCH, isOn);
    }

    public boolean getFastLoginSwitch(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_FAST_LOGIN_SWITCH);
    }

    public void setFastLoginSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_FAST_LOGIN_SWITCH, isOn);
    }

    public boolean getSoundSwitch(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_SOUND_SWITCH);
    }

    public void setSoundSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_SOUND_SWITCH, isOn);
    }

    public boolean getLoginPwdSwitch(){
        //TODO 暂时关闭该功能
//        return false;
        return PreferencesUtil.getBoolean(mContext, Constants.SP_LOGIN_PASSWORD_SWITCH);
    }

    public void setLoginPwdSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_LOGIN_PASSWORD_SWITCH, isOn);
    }

    public String getTelepassProfile(){
        return PreferencesUtil.getString(mContext, Constants.SP_LAST_TELEPASS_PROFILE);
    }

    public String getSingouProfile(){
        return PreferencesUtil.getString(mContext, Constants.SP_LAST_SINGOU_PROFILE);
    }


    public boolean getHasSecurityProfile(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_HAS_SECURITY_PROFILE);
    }

    public void setHasSecurityProfile(boolean hasProfile){
        PreferencesUtil.putBoolean(mContext, Constants.SP_HAS_SECURITY_PROFILE, hasProfile);
    }

    public void setAccountId(String accountId){
        PreferencesUtil.putString(mContext, Constants.SP_ACCOUNT_ID, accountId);
    }

    public String getAccountId(){
       return PreferencesUtil.getString(mContext, Constants.SP_ACCOUNT_ID, "");
    }

    public void setPasswordKey(String psw){
        PreferencesUtil.putString(mContext, Constants.SP_SINGOU_PASSWORD_KEY, psw);
    }

    public String getPasswordKey(){
        return PreferencesUtil.getString(mContext, Constants.SP_SINGOU_PASSWORD_KEY, Constants.DEFAULT_SINGOU_PASSWORD);
    }

    public void setNotificationSwitch(boolean isOn){
        PreferencesUtil.putBoolean(mContext,Constants.SP_NOTIFICATION_SWITCH, isOn);
    }

    public boolean getNotificationSwitch(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_NOTIFICATION_SWITCH);
    }

    public boolean getUserHasInitPsw(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_USER_HAS_INIT_SINGOU_PASSWORD, false);
    }

    public void setUserHasInitPsw(boolean hasUserInitPsw){
        PreferencesUtil.putBoolean(mContext, Constants.SP_USER_HAS_INIT_SINGOU_PASSWORD, hasUserInitPsw);

    }

    public boolean isLanguageChinese(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_LANGUADE_CHINESE, true);
    }

    public void setLanguageChinese(boolean isChinese){
        PreferencesUtil.putBoolean(mContext, Constants.SP_LANGUADE_CHINESE, isChinese);

    }

    public boolean isInitInstall(){
        return PreferencesUtil.getBoolean(mContext, Constants.SP_IS_INIT_INSTALL, true);
    }

    public void setInitInstall(boolean isInitInstall){
        PreferencesUtil.putBoolean(mContext, Constants.SP_IS_INIT_INSTALL, isInitInstall);
    }

    public String getToken(){
        return PreferencesUtil.getString(mContext, Constants.SP_PUSH_CHANNEL_ID, "");
    }

    public void setToken(String token){
        PreferencesUtil.putString(mContext, Constants.SP_PUSH_CHANNEL_ID, token);
    }

    public int getStoreId(){
        return PreferencesUtil.getInt(mContext, Constants.SP_STORE_ID, 52); //todo 为了演示不出差
    }

    public void setStoreId(int storeId){
        PreferencesUtil.putInt(mContext, Constants.SP_STORE_ID, storeId);
    }
}
